﻿using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Data;

namespace AugustVisual
{
    public class AddSubConvertor : IValueConverter
    {
        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            if (parameter == null)
            {
                parameter = 0d;
            }
            else if(typeof(string)== parameter.GetType())
            {
                parameter=  double.Parse(parameter.ToString());
            }
            else
            {
                throw new Exception($"加减转换器不识别的参数类型: {parameter.GetType().FullName}");
            }
            double d = (double)value;
            double p = (double)parameter;
            double ret = d + p;
            return ret;
        }

        public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
        {
            throw new NotImplementedException();
        }
    }
}
